package au.com.twosquared.animalfarm.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import au.com.twosquared.animalfarm.map.Map;

public class MapTest {

	@Test
	public void getTile() {

		Map map = new Map();
		int w = map.getRealWidth();
		int h = map.getRealHeight();

		for (int i = 0; i < 1000000; i++) {
			float x = (float) (Math.random() * w - 2 * Math.random() * w);
			float y = (float) (Math.random() * h - 2 * Math.random() * h);

			int actualTile = 1;

			if (x < map.getRealWidth() && y < map.getRealHeight() && x >= 0
					&& y >= 0) {
				int tx = (int) (x / map.getTileWidth());
				int ty = (int) (y / map.getTileHeight());
				actualTile = map.map[ty][tx];
			}

			assertTrue(map.getTile(x, y) == actualTile);
		}
	}
}
